
import sys
import os
import RPi.GPIO as GPIO
rootpath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(rootpath)
from MsgProcess import MsgProcess, MsgType

pin=15
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(pin,GPIO.OUT)
    
class Relay(MsgProcess):

    def Text(self, message):
        data = message['Data']      
                                   
        Triggers = ['打开']
        if any(map(lambda w: data.__contains__(w), Triggers)):
                       
            GPIO.output(pin,GPIO.HIGH)
            self.say("继电器已经打开") 
            
        Triggers = ['关闭']
        if any(map(lambda w: data.__contains__(w), Triggers)):
               
            GPIO.output(pin,GPIO.LOW)
            self.say("继电器已经关闭")  
            
            
        self.Stop() 

    